package com.example.jdksevendemo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/DemoController")
public class DemoController {


    /**
     * 逢七过小demo
     */
    @PostMapping("/fqg")
    public void contextLoads() {
        for (int i = 0; i < 100000; i++) {
            String str = String.valueOf(i);
            char[] ch = str.toCharArray();
            if ((i % 7 == 0 || checkServer(ch)) && i != 0){
                log.info("数字："+i+">>> 过;");
            }else {
                log.info("数字："+i+">>> "+i+";");
            }
        }
    }

    /**
     * 校验数字中有没有包含七
     * @param ch
     * @return
     */
    public boolean checkServer(char[] ch){
        boolean logo = false;
        for(char c: ch){
            if (c == '7'){
                return true;
            }
        }
        return logo;
    }
}
